package com.oepm.web.controller;

import com.oepm.biz.ExcelBiz;
import com.oepm.common.entity.Meta;
import com.oepm.common.entity.Result;
import com.oepm.dao.entity.QueryInfo;
import com.oepm.vo.DataVo;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@CrossOrigin
@RestController
public class ExcelController {
    @Autowired
    ExcelBiz excelBiz;

    /**
     * 导出列表
     * @param queryInfo
     * @return
     */
    @GetMapping("/date/select")
    @RequiresRoles(logical = Logical.OR,value = {"1","2","3","4"})
    public Result selectAll(QueryInfo queryInfo){
        DataVo dataVo = excelBiz.selectAll(queryInfo);
        Result result = new Result(Meta.SUCCESS, dataVo);
        return result;
    }

    /**
     * 导出学院列表
     * @param queryInfo
     * @param academy
     * @return
     */
    //修改String 为一个实体类Vo
    @GetMapping("/data/academy")
    @RequiresRoles(logical = Logical.OR,value = {"1","2","3","4"})
    public Result selectByAcademy(QueryInfo queryInfo,@RequestBody String academy){
        DataVo dataVo = excelBiz.selectByAcademy(queryInfo,academy);
        Result result = new Result(Meta.SUCCESS, dataVo);
        return result;
    }
}
